%%
%% This is file `ctex.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ctex.dtx  (with options: `sty,ctex')
%% 
%% This is a generated file.
%% 
%% Copyright 2003-2006
%% CTEX.ORG and any individual authors listed elsewhere in this file.
%% 
%% This file was generated from file(s) of the ctex package project.
%% -----------------------------------------------------------------
%% 
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.2
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%% 
%% This file may only be distributed together with a copy of original
%% source files. You may however distribute original source files
%% without such generated files. Copying of this file is authorized
%% only if either:
%% (1) you make absolutely no changes to your copy, including name; OR
%% (2) if you do make changes, you first rename it to some other name.
%% 
%% To produce the documentation run the original source files ending
%% with `.dtx' through LaTeX.
%% 
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{ctexutf8}
  [2006/06/09 v0.8 ctex
   macros package]
\newif\ifCTEX@cct \CTEX@cctfalse
\DeclareOption{CCT}{\CTEX@ccttrue}
\newif\ifCTEX@cctfont \CTEX@cctfontfalse
\DeclareOption{CCTfont}{\CTEX@ccttrue\CTEX@cctfonttrue}
\newif\ifCTEX@punct \CTEX@puncttrue
\DeclareOption{punct}{\CTEX@puncttrue}
\DeclareOption{nopunct}{\CTEX@punctfalse}
\newif\ifCTEX@space \CTEX@spacefalse
\DeclareOption{space}{\CTEX@spacetrue}
\DeclareOption{nospace}{\CTEX@spacefalse}
\newif\ifCTEX@caption \CTEX@captiontrue
\DeclareOption{nocap}{\CTEX@captionfalse}
\DeclareOption{cap}{\CTEX@captiontrue}
\newif\ifCTEX@indent \CTEX@indenttrue
\DeclareOption{noindent}{\CTEX@indentfalse}
\DeclareOption{indent}{\CTEX@indenttrue}
\newif\ifCTEX@psfont \CTEX@psfontfalse
\DeclareOption{psfont}{\CTEX@psfonttrue}
\newif\ifCTEX@fancyhdr \CTEX@fancyhdrfalse
\DeclareOption{fancyhdr}{\CTEX@fancyhdrtrue}
\newif\ifCTEX@fntef \CTEX@fnteffalse
\DeclareOption{fntef}{\CTEX@fnteftrue}
\ProcessOptions
\RequirePackage{keyval}[1999/03/16]
\ifCTEX@indent
  \RequirePackage{indentfirst}
\fi
\ifCTEX@psfont
  \RequirePackage[T1]{fontenc}
  \RequirePackage{textcomp}
  \RequirePackage{mathptmx}
  \RequirePackage[scaled]{helvet}
  \RequirePackage{courier}
\else
  \RequirePackage{type1cm}
\fi
\ifCTEX@fancyhdr
  \RequirePackage{fancyhdr}
\fi
\DeclareRobustCommand\CTeX{C\kern-.05em\TeX{}}
\newcommand*\CTEX@key{\define@key{CTEX}}
\newcommand*\CTEXoptions[1][]{\setkeys{CTEX}{#1}}
\newcommand*\CTEX@subkey[1]{\define@key{CTEX#1}}
\newcommand*\CTEXsetup[2][]{\setkeys{CTEX#2}{#1}}
\@ifclassloaded{article}{\def\CTEX@cls@article{}}{}
\@ifclassloaded{report}{\def\CTEX@cls@report{}}{}
\@ifclassloaded{book}{\def\CTEX@cls@book{}}{}
\def\ifCTEX@cls#1{%
  \expandafter\ifx\csname CTEX@cls@#1\endcsname\relax
    \expandafter\@secondoftwo
  \else
    \expandafter\@firstoftwo
  \fi}
\def\CTEX@replacecommand#1#2#3{%
  \expandafter\expandafter\expandafter\let\expandafter
    \csname #1#3\expandafter\endcsname
    \csname #2#3\endcsname
  \expandafter\expandafter\expandafter\def\expandafter
    \csname #2#3\expandafter\endcsname
    {\csname #1#3\endcsname}}
\ifCTEX@cct
  \input{ctexcctutf8.clo}
\else
  \input{ctexcjkutf8.clo}
\fi
\AtEndOfPackage{%
  \makeatletter
  \InputIfFileExists{ctexutf8.def}{}{%
    \PackageError{ctex}{%
      Can't find ctexutf8.def}{%
      There will be unexpected errors if you continue.}}
  \makeatother}
\AtEndOfPackage{%
  \makeatletter
  \InputIfFileExists{ctexutf8.cfg}{}{%
    \PackageWarning{ctex}{%
      Can't find ctexutf8.cfg}}
  \makeatother}
\newcommand*\CTEXindent{\CTEXsetfont\parindent2\ccwd}
\newcommand*\CTEXnoindent{\parindent\z@}
\ifCTEX@indent
  \AtBeginDocument{\CTEXindent}
\fi
\def\CTEX@spaceChar{\hskip \f@size \p@}
\def\baselinestretch{1.3}
\def\CTEX@fs@eight{5.02}   \def\CTEX@fs@eightskip{6.02}   %八号字    5bp
\def\CTEX@fs@seven{5.52}   \def\CTEX@fs@sevenskip{6.62}   %七号字  5.5bp
\def\CTEX@fs@ssix{6.52}    \def\CTEX@fs@ssixskip{7.83}    %小六号  6.5bp
\def\CTEX@fs@six{7.53}     \def\CTEX@fs@sixskip{9.03}     %六号字  7.5bp
\def\CTEX@fs@sfive{9.03}   \def\CTEX@fs@sfiveskip{10.84}  %小五号    9bp
\def\CTEX@fs@five{10.54}   \def\CTEX@fs@fiveskip{12.65}   %五号字 10.5bp
\def\CTEX@fs@sfour{12.05}  \def\CTEX@fs@sfourskip{14.45}  %小四号   12bp
\def\CTEX@fs@four{14.05}   \def\CTEX@fs@fourskip{16.86}   %四号字   14bp
\def\CTEX@fs@sthree{15.06} \def\CTEX@fs@sthreeskip{18.07} %小三号   15bp
\def\CTEX@fs@three{16.06}  \def\CTEX@fs@threeskip{19.27}  %三号字   16bp
\def\CTEX@fs@stwo{18.07}   \def\CTEX@fs@stwoskip{21.68}   %小二号   18bp
\def\CTEX@fs@two{22.08}    \def\CTEX@fs@twoskip{26.50}    %二号字   22bp
\def\CTEX@fs@sone{24.09}   \def\CTEX@fs@soneskip{28.91}   %小一号   24bp
\def\CTEX@fs@one{26.10}    \def\CTEX@fs@oneskip{31.32}    %一号字   26bp
\def\CTEX@fs@szero{36.14}  \def\CTEX@fs@szeroskip{43.36}  %小初号   36bp
\def\CTEX@fs@zero{42.16}   \def\CTEX@fs@zeroskip{50.59}   %初号字   42bp
\DeclareMathSizes{\CTEX@fs@eight}{\CTEX@fs@eight}{5}{5}
\DeclareMathSizes{\CTEX@fs@seven}{\CTEX@fs@seven}{5}{5}
\DeclareMathSizes{\CTEX@fs@ssix}{\CTEX@fs@ssix}{5}{5}
\DeclareMathSizes{\CTEX@fs@six}{\CTEX@fs@six}{5}{5}
\DeclareMathSizes{\CTEX@fs@sfive}{\CTEX@fs@sfive}{6}{5}
\DeclareMathSizes{\CTEX@fs@five}{\CTEX@fs@five}{7}{5}
\DeclareMathSizes{\CTEX@fs@sfour}{\CTEX@fs@sfour}{8}{6}
\DeclareMathSizes{\CTEX@fs@four}
                 {\CTEX@fs@four}{\CTEX@fs@five}{\CTEX@fs@six}
\DeclareMathSizes{\CTEX@fs@sthree}
                 {\CTEX@fs@sthree}{\CTEX@fs@sfour}{\CTEX@fs@sfive}
\DeclareMathSizes{\CTEX@fs@three}
                 {\CTEX@fs@three}{\CTEX@fs@four}{\CTEX@fs@five}
\DeclareMathSizes{\CTEX@fs@stwo}
                 {\CTEX@fs@stwo}{\CTEX@fs@sthree}{\CTEX@fs@sfour}
\DeclareMathSizes{\CTEX@fs@two}
                 {\CTEX@fs@two}{\CTEX@fs@three}{\CTEX@fs@four}
\DeclareMathSizes{\CTEX@fs@sone}
                 {\CTEX@fs@sone}{\CTEX@fs@stwo}{\CTEX@fs@sthree}
\DeclareMathSizes{\CTEX@fs@one}
                 {\CTEX@fs@one}{\CTEX@fs@two}{\CTEX@fs@three}
\DeclareMathSizes{\CTEX@fs@szero}
                 {\CTEX@fs@szero}{\CTEX@fs@sone}{\CTEX@fs@stwo}
\DeclareMathSizes{\CTEX@fs@zero}
                 {\CTEX@fs@zero}{\CTEX@fs@one}{\CTEX@fs@two}
\def\CTEX@zihao{}
\DeclareRobustCommand*\zihao[1]{\def\CTEX@zihao{#1}%
  \ifnum #11<0%
    \@tempcnta=-#1
    \ifcase\@tempcnta%
        \fontsize\CTEX@fs@szero\CTEX@fs@szeroskip%
    \or \fontsize\CTEX@fs@sone\CTEX@fs@soneskip%
    \or \fontsize\CTEX@fs@stwo\CTEX@fs@stwoskip%
    \or \fontsize\CTEX@fs@sthree\CTEX@fs@sthreeskip%
    \or \fontsize\CTEX@fs@sfour\CTEX@fs@sfourskip%
    \or \fontsize\CTEX@fs@sfive\CTEX@fs@sfiveskip%
    \or \fontsize\CTEX@fs@ssix\CTEX@fs@ssixskip%
    \else \PackageError{ctex}{%
            Undefined Chinese font size in command \protect\zihao}{%
            The old font size is used if you continue.}%
    \fi%
  \else%
    \@tempcnta=#1
    \ifcase\@tempcnta%
        \fontsize\CTEX@fs@zero\CTEX@fs@zeroskip%
    \or \fontsize\CTEX@fs@one\CTEX@fs@oneskip%
    \or \fontsize\CTEX@fs@two\CTEX@fs@twoskip%
    \or \fontsize\CTEX@fs@three\CTEX@fs@threeskip%
    \or \fontsize\CTEX@fs@four\CTEX@fs@fourskip%
    \or \fontsize\CTEX@fs@five\CTEX@fs@fiveskip%
    \or \fontsize\CTEX@fs@six\CTEX@fs@sixskip%
    \or \fontsize\CTEX@fs@seven\CTEX@fs@sevenskip%
    \or \fontsize\CTEX@fs@eight\CTEX@fs@eightskip%
    \else \PackageError{ctex}{%
            Undefined Chinese font size in command \protect\zihao}{%
            The old font size is used if you continue.}%
    \fi%
  \fi%
  \selectfont\ignorespaces}
\newif\ifCTEX@zero@
\newif\ifCTEX@previous@
\newif\ifCTEX@null@
\newcount\CTEX@q
\newcount\CTEX@r
\def\CTEX@appendstring#1#2{%
  \expandafter\def\expandafter#1\expandafter{#1#2}}
\def\CTEX@appendnumber#1#2{%
  \ifcase #2\relax
    \ifCTEX@null@
      \CTEX@appendstring{#1}{\CTEX@null}%
    \else
      \CTEX@appendstring{#1}{\CTEX@zero}%
    \fi
  \or \CTEX@appendstring{#1}{\CTEX@one}%
  \or \CTEX@appendstring{#1}{\CTEX@two}%
  \or \CTEX@appendstring{#1}{\CTEX@three}%
  \or \CTEX@appendstring{#1}{\CTEX@four}%
  \or \CTEX@appendstring{#1}{\CTEX@five}%
  \or \CTEX@appendstring{#1}{\CTEX@six}%
  \or \CTEX@appendstring{#1}{\CTEX@seven}%
  \or \CTEX@appendstring{#1}{\CTEX@eight}%
  \or \CTEX@appendstring{#1}{\CTEX@nine}%
  \fi}
\def\CTEX@splitnumber#1{%
  \CTEX@q #1\relax
  \CTEX@r #1\relax
  \divide\CTEX@q \@M
  \begingroup
    \multiply\CTEX@q \@M
    \advance\CTEX@r -\CTEX@q
    \ifnum\CTEX@r = \z@
      \xdef\CTEX@low{}%
    \else
      \xdef\CTEX@low{\number\CTEX@r}%
    \fi
  \endgroup
  \ifnum\CTEX@q > \z@
    \CTEX@r \CTEX@q
    \divide\CTEX@q \@M
    \begingroup
      \multiply\CTEX@q \@M
      \advance\CTEX@r -\CTEX@q
      \ifnum\CTEX@r = \z@
        \xdef\CTEX@high{}%
      \else
        \xdef\CTEX@high{\number\CTEX@r}%
      \fi
    \endgroup
    \ifnum\CTEX@q > \z@
      \xdef\CTEX@yi{\number\CTEX@q}%
    \else
      \xdef\CTEX@yi{}%
    \fi
  \else
    \xdef\CTEX@high{}%
    \xdef\CTEX@yi{}%
  \fi
}
\def\CTEX@processnumber#1#2{%
  \CTEX@zero@false
  \CTEX@q #2\relax
  \CTEX@r #2\relax
  \divide\CTEX@q \@m
  \ifnum\CTEX@q = \z@
    \ifCTEX@previous@
      \CTEX@zero@true
    \fi
  \else
    \ifCTEX@zero@
      \CTEX@appendstring{#1}{\CTEX@zero}%
    \fi
    \CTEX@appendnumber{#1}{\CTEX@q}%
    \CTEX@appendstring{#1}{\CTEX@thousand}%
    \CTEX@previous@true
    \CTEX@zero@false
  \fi
  \multiply\CTEX@q \@m
  \advance\CTEX@r -\CTEX@q
  \CTEX@q \CTEX@r
  \divide\CTEX@q 100\relax
  \ifnum\CTEX@q = \z@
    \ifCTEX@previous@
      \CTEX@zero@true
    \fi
  \else
    \ifCTEX@zero@
      \CTEX@appendstring{#1}{\CTEX@zero}%
    \fi
    \CTEX@appendnumber{#1}{\CTEX@q}%
    \CTEX@appendstring{#1}{\CTEX@hundred}%
    \CTEX@previous@true
    \CTEX@zero@false
  \fi
  \multiply\CTEX@q 100
  \advance\CTEX@r -\CTEX@q
  \CTEX@q \CTEX@r
  \divide \CTEX@q 10\relax
  \ifnum\CTEX@q = \z@
    \ifCTEX@previous@
      \CTEX@zero@true
    \fi
  \else
    \ifCTEX@zero@
      \CTEX@appendstring{#1}{\CTEX@zero}%
    \fi
    \ifnum\CTEX@q = \@ne
      \ifCTEX@previous@
        \CTEX@appendstring{#1}{\CTEX@one}%
      \fi
    \else
      \CTEX@appendnumber{#1}{\CTEX@q}%
    \fi
    \CTEX@appendstring{#1}{\CTEX@ten}%
    \CTEX@previous@true
    \CTEX@zero@false
  \fi
  \multiply\CTEX@q 10
  \advance\CTEX@r -\CTEX@q
  \ifnum\CTEX@r = \z@
  \else
    \ifCTEX@zero@
      \CTEX@appendstring{#1}{\CTEX@zero}%
    \fi
    \CTEX@appendnumber{#1}{\CTEX@r}%
    \CTEX@previous@true
  \fi}
\DeclareRobustCommand\CTEXnumber[2]{%
  \def#1{}%
  \CTEX@null@false
  \CTEX@q #2\relax
  \ifnum\CTEX@q < \z@
    \multiply\CTEX@q \m@ne
    \CTEX@appendstring{#1}{\CTEX@minus}%
  \fi
  \CTEX@previous@false
  \CTEX@zero@false
  \ifnum\CTEX@q = \z@
    \CTEX@appendstring{#1}{\CTEX@zero}%
  \else
    \CTEX@splitnumber{\CTEX@q}%
    \ifx\CTEX@yi \@empty
    \else
      \CTEX@processnumber{#1}{\CTEX@yi}%
      \CTEX@appendstring{#1}{\CTEX@hundredmillion}%
    \fi
    \ifx\CTEX@high \@empty
    \else
      \CTEX@processnumber{#1}{\CTEX@high}%
      \CTEX@appendstring{#1}{\CTEX@tenthousand}%
    \fi
    \ifx\CTEX@low \@empty
    \else
      \ifx\CTEX@yi \@empty
      \else
        \ifx\CTEX@high \@empty
          \CTEX@appendstring{#1}{\CTEX@zero}% this catches 100002345
        \fi
      \fi
      \CTEX@processnumber{#1}{\CTEX@low}%
    \fi
  \fi}
\def\CTEX@getdigit#1#2\@nil{%
  \edef\CTEX@tempa{#1}%
  \edef\CTEX@tempb{#2}}
\DeclareRobustCommand\CTEXdigits[2]{%
  \def#1{}%
  \CTEX@null@true
  \edef\CTEX@tempa{}%
  \edef\CTEX@tempb{#2}%
  \ifx\CTEX@tempb \@empty
  \else
    \loop
      \expandafter\CTEX@getdigit\CTEX@tempb\@nil
      \CTEX@appendnumber{#1}{\CTEX@tempa}%
      \ifx\CTEX@tempb \@empty
      \else
    \repeat
  \fi}
\DeclareRobustCommand\CTEXcounter[1]{%
  \@ifundefined{c@#1}{}{%
    \CTEXnumber{\reserved@a}{\@arabic\csname c@#1\endcsname}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\csname cc@#1\endcsname%
    \expandafter{\reserved@a}}}
\AtBeginDocument{%
  \makeatletter%
  \@ifundefined{CTEX@save@setcounter}{%
    \let\CTEX@save@setcounter\setcounter%
    \def\setcounter#1#2{%
        \CTEX@save@setcounter{#1}{#2}%
        \CTEXcounter{#1}}}{}
  \@ifundefined{CTEX@save@addtocounter}{%
    \let\CTEX@save@addtocounter\addtocounter%
    \def\addtocounter#1#2{%
        \CTEX@save@addtocounter{#1}{#2}%
        \CTEXcounter{#1}}}{}
  \@ifundefined{CTEX@save@stepcounter}{%
    \let\CTEX@save@stepcounter\stepcounter%
    \def\stepcounter#1{%
        \CTEX@save@stepcounter{#1}%
        \CTEXcounter{#1}}}{}
  \makeatother}
\def\chinese#1{%
  \@ifundefined{cc@#1}{\CTEX@null}{\csname cc@#1\endcsname}}
\ifCTEX@caption
  \let\CTEX@save@refstepcounter\refstepcounter
  \def\refstepcounter#1{\stepcounter{#1}%
    \protected@edef\@currentlabel
      {\csname p@#1\endcsname%
       \@ifundefined{CTEX@the#1}%
         {\csname the#1\endcsname}%
         {\csname CTEX@the#1\endcsname}%
       }}%
\fi
\let\CTEX@todayold\today
\let\CTEX@todaysmall\today
\let\CTEX@todaybig\today
\ifCTEX@caption
  \renewcommand*\today{\CTEX@todaysmall}
\fi
\CTEX@key{today}{\CTEX@settoday{#1}}
\newcommand*\CTEX@settoday[1]{%
  \@ifundefined{CTEX@today#1}
    {\PackageError{ctex}{%
       unknown today format}{%
       Available today format are "old", "small", and "big".}}
    {\renewcommand*\today{\csname CTEX@today#1\endcsname}}}
\endinput
%%
%% End of file `ctexutf8.sty'.
